package com.jayam.gas.client.presenter;

import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasWidgets;
import com.jayam.gas.client.OrderServiceAsync;
import com.jayam.gas.client.event.AddOrderEvent;
import com.jayam.gas.client.view.AddOrderView;
import com.jayam.gas.shared.OrderDetails;

public class AddOrderPresenter implements Presenter, AddOrderView.Presenter<OrderDetails> {

	private final HandlerManager eventBus;
	private final AddOrderView<OrderDetails> view;

	public AddOrderPresenter(final OrderServiceAsync rpcService, final HandlerManager eventBus,
			final AddOrderView<OrderDetails> view) {
		this.eventBus = eventBus;
		this.view = view;
		this.view.setPresenter(this);
	}

	@Override
	public void onAddButtonClicked() {
		eventBus.fireEvent(new AddOrderEvent());
	}

	@Override
	public void go(final HasWidgets container) {
		container.clear();
		container.add(new HTML("gdgd"));
		container.add(view.asWidget());
		Window.alert(container.toString());
	}

}
